/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.unal.bioingenium.kbmed.util.checker;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Alejandro Riveros Cruz
 */
class Checker extends Thread {

    private boolean continueChecing = true;
    private String message;
    private int cycle = 5000;
    private Object objectReference;

    public Checker(Object object, String message) {
        this.objectReference = object;
        this.message = message;
    }

    public Checker(Object object, String message, int cycle) {
        this.objectReference = object;
        this.message = message;
        this.cycle = cycle;
    }

    @Override
    public void run() {
        while (continueChecing) {
            try {
                System.out.println(message + objectReference);
                Thread.sleep(cycle);
            } catch (InterruptedException ex) {
                Logger.getLogger(ThreadedChecker.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public void stopChecking() {
        continueChecing = false;
    }
}
